// pages/details/details.js
import Toast from '@vant/weapp/toast/toast'
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
    //   console.log(options);
      this.setData({
        foodId:options.foodId,
        foodName:options.foodName,
        foodPath:options.foodUrl,
        foodDetail:options.foodDetail,
        foodPrice:options.foodPrice,
        foodStaple:options.foodStaple
       });
    },
    onclick: function(){
        var that = this
        wx.request({
            url: 'http://localhost:8080/orderCart/addOne?cuisineName=' + that.data.foodName 
            + '&cuisineImg=' + that.data.foodPath 
            + '&cuisinePrice=' + that.data.foodPrice 
            + '&userId=' + '1'
            + '&creater=' + 'admin',
            data: {},
            method: 'POST',
            header: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            success: function (res) {
                console.log(res)
                if (res.data.state == 1) {
                    that.setData({
                        title: res.data.data
                    })
                } else {
                    wx.showToast({
                        title: res.data.msg
                    });
                }
                this.onLoad();
            }
        })
    }
})